<template>
    <div class="info-attr-module">

        <div class="title">
            赛事信息
        </div>
        <div class="attr-data">
            <div class="item">
                <span>参与代表对队</span>
                <div>{{teaminfo.team_name}}</div>
            </div>
            <div class="item">
                <span>领队</span>
                <div>{{teaminfo.real_name}}</div>
            </div>
        </div>
        <div class="title wt">
            赛事信息
        </div>
        <div class="attr-data">
            <div class="item">
                <span>参与赛事</span>
                <div>{{record.match_name}}</div>
            </div>
            <div class="item">
                <span>参与赛项</span>
                <div>{{record.item_name}}</div>
            </div>
            <div class="item">
                <span>参赛组别</span>
                <div>{{record.group_name}}</div>
            </div>
            <div class="item">
                <span>参赛选手</span>
                <div>{{record.real_name}}</div>
            </div>
            <div class="item">
                <span>队伍名称</span>
                <div>{{record.team_name}}</div>
            </div>
            <div class="item">
                <span>指导老师</span>
                <div>{{record.teachers}}</div>
            </div>
            <div class="item">
                <span>比赛时间</span>
                <div>{{matchInfo.begindate}}</div>
            </div>
            <div class="item">
                <span>报名时间</span>
                <div>{{record.create_date}}</div>
            </div>
        </div>
        <div class="title">
            选手信息
        </div>
        <div class="attr-data">
            <div class="item">
                <span>姓名</span>
                <div>{{this.userInfo.real_name}}</div>
            </div>
            <div class="item">
                <span>性别</span>
                <div>{{this.userInfo.sex==1?'男':'女'}}</div>
            </div>
            <div class="item">
                <span>学习/单位</span>
                <div>{{this.userInfo.company}}</div>
            </div>
            <div class="item">
                <span>参赛证号</span>
                <div>{{hideTicket(this.userInfo.ticket)}}</div>
            </div>
        </div>
        <div style="height:4rem"></div>

    </div>
</template>


<script lang="ts" >

import {defineComponent, reactive, toRefs} from "vue";
import listService from "@/utils/listService";
import {getCache} from "@/utils/cache";
import router from "@/router";
import baseService from "@/utils/baseService";

export default defineComponent({
  mounted(){
    this.id=this.$route.query.id ;
    this.userId =this.$route.query.userId ;
    this.queryInfo();
  },

  data() {
    return {
      id : null as any,
      userId:null as any,
      userInfo:{
        ticket: '',
        sex: 1,
        header: "",
        real_name: "",
        company: "",
        id: "1"

      },
      teaminfo:{
        real_name: "",
        team_name: ""
      },
      record:{
        create_date:'',
        classname: "创意类",
        group_name: "初中组",
        teachers: "姓名7",
        item_name: "团体花样表演",
        real_name: "王莉莉、张悦悦、宋婷婷",
        id: "1655117165470240769",
        typename: "团体赛",
        team_name: "214234",
      }
      ,
      matchInfo:{
        id:'',
        match_name:'',
        signdate:'',
        begindate:'',
      }
    };
  },

  methods: {
    queryMatch(id:string){
      this.matchInfo.id
          = id;
      this.queryUserInfo(this.userId);
      baseService.get('/front/fast/match/match/info?id='+id).then(e=>{
        this.matchInfo= e.data;
      })
    },
    queryInfo(){
      if(!this.id){
        return;
      }
      baseService.get('/front/fast/match/matchRecordItem/info?myinfo=1&id='+this.id).then(e=>{
        this.record= e.data;
        this.queryMatch(e.data.match_id);
        this.queryTeamInfo(e.data.team_id);
      })
    }
    //查询赛项信息
    ,queryTeamInfo(id:any){
      baseService.get("/front/fast/user/team/info?id="+id).then((e:any)=>{
        if(e.code=='0'){
          this.teaminfo = e.data;
        }
      });
    }//查询赛项信息
    ,queryUserInfo(id:any){
      baseService.get("/front/fast/user/userInfo/info?id="+id+"&matchId="+this.matchInfo.id).then((e:any)=>{
        if(e.code=='0'){
          this.userInfo = e.data;
        }
      });
    },
    /**
     * 证件号隐藏前三位
     */
    hideTicket(ticket: string) {
      //隐藏前三位
      return ticket && ticket.length>3 ? ticket.substr(3, ticket.length): ticket;
    }


  }
});
</script>


<style lang="scss" scoped>
@import "./style.scss";
</style>
